class TripwireRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	TripwireRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return 0; }

	void DrawTrip(RendererBase *renderer)
	{
		renderer->Draw(Face(Point3f(8, 15, 7.75f), Point3f(12, 15, 7.75f), Point3f(12, 15, 8.25f), Point3f(8, 15, 8.25f), Colorb::White, Texture, Point2i(13 * 16, 10 * 16), 16, 2));
		renderer->Draw(Face(Point3f(12, 15, 7.75f), Point3f(16, 15, 7.75f), Point3f(16, 15, 8.25f), Point3f(12, 15, 8.25f), Colorb::White, Texture, Point2i(13 * 16, 10 * 16), 16, 2));
	}

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		auto &north = schematic->GetBlock(position.X, position.Y, position.Z + 1);
		auto &south = schematic->GetBlock(position.X, position.Y, position.Z - 1);
		auto &east = schematic->GetBlock(position.X + 1, position.Y, position.Z);
		auto &west = schematic->GetBlock(position.X - 1, position.Y, position.Z);

		bool connectedNorth = (north != Block::Empty && (north.ID == block.ID || north.ID == 131));
		bool connectedSouth = (south != Block::Empty && (south.ID == block.ID || south.ID == 131));
		bool connectedEast = (east != Block::Empty && (east.ID == block.ID || east.ID == 131));
		bool connectedWest = (west != Block::Empty && (west.ID == block.ID || west.ID == 131));

		if (!(connectedNorth || connectedSouth || connectedEast || connectedWest))
			connectedNorth = connectedSouth = true;

		if (connectedEast)
			DrawTrip(renderer);
		if (connectedWest)
		{
			renderer->PushState();
			renderer->Translate(8, 8, 8);
			renderer->Rotate(180, 0, 1, 0);
			renderer->Translate(-8, -8, -8);
			DrawTrip(renderer);
			renderer->PopState();
		}
		if (connectedNorth)
		{
			renderer->PushState();
			renderer->Translate(8, 8, 8);
			renderer->Rotate(-90, 0, 1, 0);
			renderer->Translate(-8, -8, -8);
			DrawTrip(renderer);
			renderer->PopState();
		}
		if (connectedSouth)
		{
			renderer->PushState();
			renderer->Translate(8, 8, 8);
			renderer->Rotate(90, 0, 1, 0);
			renderer->Translate(-8, -8, -8);
			DrawTrip(renderer);
			renderer->PopState();
		}
	}
};